/**
 * 
 */
package fr.fermeManager.library.dao;

import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

import org.apache.commons.math.random.RandomData;
import org.apache.commons.math.random.RandomDataImpl;

import fr.fermeManager.library.model.beans.Transaction;
import fr.fermeManager.library.model.beans.TypeTransaction;

/**
 * @author Mo
 *
 */
public class DaoTransactionImpl implements DaoTransaction {
	
	private int cpt = 8;

	public List<Transaction> getFermeTransactions(int idFerme,boolean isAdmin) {
		
		List<Transaction> listeTmp = new ArrayList<Transaction>();
		
		// de 1 a 8
		Date dateDebut = new GregorianCalendar(2012, 1, 1).getTime();
		Date dateFin = new GregorianCalendar(2013, 1, 1).getTime();
		
		RandomData randomData = new RandomDataImpl( );
		
		for (int i = 0; i < 10; i++) {
			
			Transaction transaction1 = new Transaction();
			transaction1.setActif(true);
			transaction1.setDescription("Transaction desc "+i);
			transaction1.setId(i);
			transaction1.setLibelle("Trans"+i);
			transaction1.setMontant(randomData.nextInt(200, 5000));
			
			TypeTransaction typeTransac1 = new TypeTransaction(true);
			typeTransac1.setId(randomData.nextInt(1,8));
			transaction1.setTypeTransaction(typeTransac1);
			
			long number = randomData.nextLong(dateDebut.getTime(),dateFin.getTime());
			GregorianCalendar gre = new GregorianCalendar();
			gre.setTime(new Date(number));
			transaction1.setDateCreation(gre);
			
			listeTmp.add(transaction1);
			
		}
		
		return listeTmp;
	}

	public Transaction ajouterTransaction(int idFerme, Transaction nouveauTransac) {
		nouveauTransac.setId(cpt);
		cpt++;
		return nouveauTransac;
	}

	public void supprimerTransaction(int idTransaction) {
		
	}

	public void modifierTransaction(Transaction transacParam) {
	}

	@Override
	public boolean existeTransactionsActifsForFerme(int idFerme) throws Exception {
		return false;
	}

	@Override
	public boolean existeTransactionsActifsForTypeTransaction(int idTransaction) throws Exception {
		return false;
	}


}
